package io.renren.wechat.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.wechat.entity.UsersEntity;
import io.renren.wechat.vo.FriendVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.wechat.entity.MyFriendsEntity;
import io.renren.wechat.service.MyFriendsService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;




/**
 * 
 *
 * @author hjy
 * @email 不告诉你
 * @date 2021-06-02 21:05:28
 */
@Api(tags = "myfriends")
@RestController
@RequestMapping("wechat/myfriends")
public class MyFriendsController {
    @Autowired
    private MyFriendsService myFriendsService;

    /**
     * 查询好友
     */
    @ApiOperation(value = "好友查询")
    @GetMapping("/friend/{myUserId}")
    public R getUserFriendById(@PathVariable("myUserId") String myUserId){
        List<FriendVo> list = myFriendsService.seekFriend(myUserId);
        return R.ok().put("page", list);
    }

    /**
     * 列表
     */
    @ApiOperation(value = "基础列表查询")
    @ApiImplicitParam(name = "params",value = "聚合查询参数",required = false)
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = myFriendsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation(value = "基础id详情")
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		MyFriendsEntity myFriends = myFriendsService.getById(id);

        return R.ok().put("myFriends", myFriends);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "基础保存")
    @PostMapping("/save")
    public R save(@RequestBody MyFriendsEntity myFriends){
		myFriendsService.save(myFriends);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value = "基础修改")
    @PostMapping("/update")
    public R update(@RequestBody MyFriendsEntity myFriends){
		myFriendsService.updateById(myFriends);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation(value = "基础删除")
    @GetMapping("/delete/{id}")
    public R delete(@PathVariable("id") String id){
		myFriendsService.remove(id);
        return R.ok();
    }

}
